home *** CD-ROM | disk | FTP | other *** search
- Path: news.scruz.net!usenet
- From: Dave Navarro <dave@powerbasic.com>
- Newsgroups: comp.lang.c
- Subject: Re: Determining the serial number on a hard disk
- Date: Thu, 07 Mar 1996 15:34:15 -0800
- Organization: PowerBASIC, Inc. (http://www.powerbasic.com)
- Message-ID: <313F7277.506C@powerbasic.com>
- References: <207_9602292012@dudd.uniserve.com>
- NNTP-Posting-Host: 165.227.103.90
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (Win95; I)
-
- > jo> I'm using MSVC. Does anyone know how to determine the serial number
- > jo> of a disk. This is the number you get when you issue a VOL command
- > jo> from the DOS prompt. I was thinking of using this number as a method
- > jo> of copy protection.
- > jo> Anybody know the sector, head, and cylinder where this number is
- > jo> stored?
- > I wouldn't know that... but if you get ahold of an interrupt list, you
- > might do best to use the bios to tell you that. Just use int86 or
- > whatever.
-
- Here's some Basic code that can be easily translated:
-
- '
- ' DISKID.BAS reports disk volume and serial number from boot sector
- '
- ' Author: Christy Gemmell (christy.gemmell@almac.co.uk)
- ' Date: 12/4/1992
- '
- ' Captured from alt.lang.basic newsgroup on July 20, 1995 and converted
- ' to PowerBASIC by Dave Navarro, Jr. (dave@powerbasic.com)
- '
-
- %AX = 1 : %BX = 1
- %CX = 1 : %DX = 1
- %DS = 8
-
- TYPE ParaBlock
- Info AS INTEGER ' Call information level
- SerNo AS LONG ' Disk serial number
- Label AS STRING * 11 ' Volume label
- FlSys AS STRING * 8 ' File system type
- END TYPE
-
- INPUT "Which drive - <Enter> for default"; D$
-
- GetDiskID D$, S$, V$, F$
- PRINT
- PRINT "Disk information for drive "; D$
- PRINT "----------------------------"
- PRINT "Volume label : "; V$
- PRINT "Serial number : "; S$
- PRINT "File system : "; F$
- END
-
- SUB GetDiskID (Drive$, Serial$, Volume$, FileSys$)
-
- DIM Para AS ParaBlock ' Buffer for drive parameter block
-
- Para.Info = 0 ' Information level always zero
-
- REG %AX, &H440D ' Generic IOCTL device request
- IF Drive$ = "" THEN ' If no drive specified
- REG %BX, 0 ' then use default
- ELSE ' Otherwise convert
- REG %BX, ASC(UCASE$(Drive$)) - 64 ' drive letter to number
- END IF ' A: = 1, B: = 2 etc
- REG %CX, &H0866 ' Subfunction: get drive ID
- REG %DX, VARPTR(para) ' Offset of buffer in DX
- REG %DS, VARSEG(Para) ' Segment of buffer in DS
- CALL INTERRUPT &H21 ' Invoke DOS
-
- Serial$ = HEX$(Para.SerNo) ' Get serial number
- Volume$ = Para.Label ' Get volume label
- FileSy$ = Para.FlSys ' Get file system type
-
- END SUB
-
- --Dave
-